<?php
/**
* This is used as a shortcut for file links.  It allows us to use the file id only to retrieve, rather
*       than also needing the root or filename.
*
* @param int $file_ident The file to load
**/
    define("context", "redirect");

    // Load libraries.
    require_once('../../../includes.php');
    require_once('../model/file.php');
    require_once('../model/user.php');
    global $CFG;

    $file_ident = intval(required_param('file_ident'));

    $file = folio_file::SelectWhereIdent( $file_ident );

    if ( $file == false) {
        die( __gettext('This file has been deleted by a user.'));
    } else {
        $user = folio_user::SelectWhereIdent( $file->files_owner ) ;
        $redirect_url = $CFG->wwwroot . "{$user->username}/files/" .
                        "{$file->folder}/{$file->ident}/{$file->originalname}";
    }

    header("Location: " . $redirect_url);

?>
